import { defineComponent, h } from 'vue';

export default defineComponent({
  props: {
    state: Boolean,
  },
  setup(props, { slots }) {
    let render: any = () => 'no default slot';
    const defaultSlot = slots.default;

    if (typeof defaultSlot === 'function') {
      render = (state: boolean) => defaultSlot({ state });
    }

    render = (state: boolean) => {
      if (state && typeof defaultSlot === 'function') {
        return defaultSlot({ state });
      } else {
        return state + '';
      }
    };

    return () => h('div', {}, [render(props.state)]);
  },
});
